﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SchemaMonitor.json;
using System.Runtime.Serialization;

namespace SchemaMonitor
{
    [DataContract]
    public class CDiff
    {
        [DataMember(Order = 1)] public List<int> ParentTagIds   { get; set; }
        [DataMember(Order = 2)] public CField    Before         { get; set; }
        [DataMember(Order = 3)] public CField    After          { get; set; } 

        public CDiff() { }

        public string Path
        {
            get
            {
                var tag = (Before ?? After).Tag;
                if (null == ParentTagIds || ParentTagIds.Count == 0)
                    return tag?.TagName;

                var parents = CTag.Cache.GetByIds(ParentTagIds);
                return string.Concat(parents.Path, ".", tag?.TagName);
            }
        }
    }
}
